package com.api.oa.mapper;

import com.api.oa.model.entity.YQRequestAss;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQRequestAssMapper {

    @Insert("insert into  yq_request_ass  (" +
        "orderCode," +
        "userId," +
        "createdAt," +
        "userRole" +
    ") " +
    "values " +
    "(" +
        "#{entity.orderCode}," +
        "#{entity.userId}," +
        "#{entity.createdAt}," +
        "#{entity.userRole}" +
    ")" )
    @Options(useGeneratedKeys = true, keyProperty = "noticeId", keyColumn = "id")
    Integer insert(@Param("entity") YQRequestAss entity);



    @Update("update  yq_request_ass  set " +
        "userId = #{entity.userId}" +
    " where orderCode = #{entity.orderCode} and userRole = #{entity.userRole} ")
    Integer update(@Param("entity") YQRequestAss  entity);


    @Delete("delete from yq_request_ass where userId=#{id}")
    void delete(@Param("id") Long id);


    @Select("select * from  yq_request_ass  where noticeId = #{id}")
    List<YQRequestAss> list(@Param("id") Long pid);


    @Select("select * from  yq_request_ass  where noticeId = #{id} limit 1")
    YQRequestAss findOne(@Param("id") Long id);

    @Select("select * from  yq_request_ass  where orderCode = #{id} and userRole = #{userRole} limit 1")
    YQRequestAss findOneByOrder(@Param("id") String id,@Param("userRole") Integer userId);

}

